<script lang="ts" setup>
import AOS from 'aos';
import 'aos/dist/aos.css';
import { useRouter } from 'vue-router';

// 在组件挂载时初始化AOS
onMounted(() => {
  AOS.init();
});
const router = useRouter()

const props = defineProps({
  items: {
    type: Array,
    request: true,
  },
})

const Learnmore = (item: { id: number }) => {
  router.push(`/article-details${item.id}`)
  console.log(item.id, '点击传入的值')
}
</script>

<template>
  <div v-for="(item, index) in props.items" :key="index" data-aos="fade-up" data-aos-duration="2000" :id="item.href">
    <div class="project">
      <div class="project-image">
        <img :src="item.image" alt="" />
      </div>
      <div class="project-content">
        <h1 class="project-content-title">{{ item.title }}</h1>
        <p class="project-content-introduce">
          {{ item.content }}
        </p>
        <div style="width: 65%; text-align: right">
          <a-button type="primary" size="large" @click="Learnmore(item)" class="project-content-button">了解更多</a-button>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.project {
  width: 100%;
  margin-top: 100px;
  display: flex;
  justify-content: center;
  justify-content: space-around;
  padding-top: 200px;

  //  左边元素
  &-image {
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    img {
      width: 550px;
      height: 480px;
    }
  }

  //  右边元素
  &-content {
    width: 50%;
    height: 100%;
    display: flex;
    flex-direction: column;

    &-title {
      margin-top: 50px;
      font-size: 35px;
    }

    &-introduce {
      width: 70%;
      font-size: 21px;
      margin-top: 50px;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      line-clamp: 3;
      overflow: hidden;
    }

    &-button {
      margin-top: 40px;
      padding: 0 30px;
    }
  }
}

/* For demo */
:deep(.slick-slide) {
  height: 600px;
  background: #fff;
  overflow: hidden;
}

:deep(.slick-slide h3) {
  color: #fff;
}
</style>
